<?php
/**
 * Created by PhpStorm.
 * User: jack.shan
 * Date: 2020/9/13
 * Time: 9:59
 */
namespace app\index\controller;

use app\index\BaseController;
use think\facade\Db;
use think\facade\View;

class Tree extends BaseController
{
    public function index()
    {
        return View::fetch();
    }

    public function tdata()
    {
        $dataStr = '[{"id":1,"pid":0,"title":"1-1"},{"id":2,"pid":0,"title":"1-2"},{"id":3,"pid":0,"title":"1-3"},{"id":4,"pid":1,"title":"1-1-1"},{"id":5,"pid":1,"title":"1-1-2"},{"id":6,"pid":2,"title":"1-2-1"},{"id":7,"pid":2,"title":"1-2-3"},{"id":8,"pid":3,"title":"1-3-1"},{"id":9,"pid":3,"title":"1-3-2"},{"id":10,"pid":4,"title":"1-1-1-1"},{"id":11,"pid":4,"title":"1-1-1-2"}]';

        $data = json_decode($dataStr, 1);

        return json($data);
    }
}